﻿using ConfigurationCommon;
using SqlSugar;
using System.Data;

namespace DataBaseCommon
{
    /// <summary>
    /// mysql+sql db
    /// </summary>
    public class SqlSugarClientScopedHelper
    {
        ConfigurationScopeHelper _configurationScopeHelper;

        public SqlSugarClientScopedHelper(ConfigurationScopeHelper configurationScopeHelper)
        {
            _configurationScopeHelper = configurationScopeHelper;
        }

        public SqlSugarClient GetMySqlDb()
        {
            return new SqlSugarClient(new ConnectionConfig() { ConnectionString = _configurationScopeHelper._userMysqlConnectionString, DbType = SqlSugar.DbType.MySql, IsAutoCloseConnection = true });
        }

        public SqlSugarClient GetSqlDb(string constr)
        {
            return new SqlSugarClient(new ConnectionConfig() { ConnectionString = constr, DbType = SqlSugar.DbType.SqlServer, IsAutoCloseConnection = true });
        }

        public static SqlSugarClient GetMySqlDbStatic(string constr) {
           return  new SqlSugarClient(new ConnectionConfig() { ConnectionString = constr,DbType=SqlSugar.DbType.MySql,IsAutoCloseConnection=true });
        }

        public static SqlSugarClient GetSqlDbStatic(string constr)
        {
            return new SqlSugarClient(new ConnectionConfig() { ConnectionString = constr, DbType = SqlSugar.DbType.SqlServer, IsAutoCloseConnection = true });
        }
    }
}